<?php

defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'';
if($_RQ['op']=='wxapp_tmplIds'){
	exi('');
}
if($_RQ['op']=='get_accpagetype'){
	if(get_access_setting($_RQ['pluginname'])){
		exi('close_one_page');
	}else{
		exi('isone_page');
	}
}
if($_RQ['op']=='get_plugins'){
	//应用
	$wxapp_id=intval($_RQ['id']);
	$params=array('type <>'=>4);
	if($_RQ['title']){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=trim($_RQ['title']);
	}
	$fields=array('id','title','image','version','name');
	$pindex = max(1, $_RQ['page']);
	$psize = 15;
	$total='';
	$list=pdo_getslice('core_plugins',$params,array($pindex,$psize),$total,$fields);
	if($list){
		foreach($list as &$item){
			//整理返回数据
			if($_RQ['many']=='1'){
				$item['res']=array('name'=>$item['name'],'title'=>$item['title'],'image'=>$item['image']);
			}else{
				$item['res']=$item['name'];
			}
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'list'=>array('data'=>'list','del_one'=>false,'delall'=>false,'edit'=>false,'list'=>array(
			array('type'=>'string','title'=>'应用名称','name'=>'title'),
			array('type'=>'image','title'=>'应用LOGO','name'=>'image'),
			array('type'=>'string','title'=>'应用标识','name'=>'name'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'res','title_field'=>'name','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title'),
	);
	$return['htmls']=$htmls;
	exi($return);
}